package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.TeachplanDTO;
import com.xuecheng.api.content.model.vo.TeachplanVO;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.ext.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author wuyunyun
 * @data 2021/10/9 22:44
 */
@Mapper
public interface TeachplanConvert {
    TeachplanConvert INSTANCE = Mappers.getMapper(TeachplanConvert.class);

    @Mappings({
            @Mapping(source = "childrenNodes" ,target = "teachPlanTreeNodes"),
            @Mapping(source = "id" ,target = "teachPlanId")
    })
    TeachplanDTO node2Dto(TeachplanNode node);


    List<TeachplanDTO> nodes2Dtos(List<TeachplanNode> nodes);

    TeachplanDTO vo2Dto(TeachplanVO vo);

    @Mapping(source = "id" ,target = "teachPlanId")
    TeachplanDTO entity2Dto(Teachplan po);

//    List<TeachplanDTO> entitys2Dtos(List<Teachplan> pos);

    @Mapping(source = "teachPlanId" ,target = "id")
    Teachplan dto2entity( TeachplanDTO  dto);

    List<Teachplan> dtos2entitys(List<TeachplanDTO> dtos);


}
